<table width="100%"><tr><td width="20%">
<a href="../index.html">&lt; index</a><br />
<a href="index.html">&lt; 5. Image toolkit</a>
</td><td width="60%">
<p align="center">
=====================================<br />
5.9 Modifying an image<br />
=====================================<br />
</p></td><td width="20%">
</td></tr></table>
<style type="text/css">
.code { color:#444444; background-color:#EEEEEE;}
pre { color:#444444; background-color:#EEEEEE;}
table.param td { border : 1px solid #000000; }
th { background-color: #44BBFF; color: #FFFFFF }
table.none td { border : 0 }
</style>
You can resize an image, scaling its content, using this function :<br/>
<p class="code"><pre>
C++ : void TCODImage::scale(int neww, int newh)
C   : void TCOD_image_scale(TCOD_image_t image,int neww, int newh)
Py  : image_scale(image, neww,newh)
</pre></p>
If neww &lt; oldw or newh &lt; oldh, supersampling is used to scale down the image. Else the image is scaled up using nearest neightbor.<br />
<table class="param">
<tr><th>Parameter</th><th>Description</th></tr>
<tr><td>image</td><td>In the C and python version, the image handler, obtained with the <a href="image_load.html">load</a> function.</td></tr>
<tr><td>neww,newh</td><td>The new size of the image.</td></tr>
</table>
Example :<br />
<p class="code"><pre>
C++ : TCODImage *pix = TCODImage("mypix.bmp");
      pix->scale(10,10);
C   : TCOD_image_t pix = TCOD_image_new(80,50);
      TCOD_image_scale(pix,10,10);
Py  : pix = libtcod.image_new(80,50)
      libtcod.image_scale(pix,10,10)
</pre></p>
<br />
You can also flip the image, either horizontally or vertically : <br />
<p class="code"><pre>
C++ : void TCODImage::hflip()
      void TCODImage::vflip()
C   : void TCOD_image_hflip(TCOD_image_t image)
      void TCOD_image_vflip(TCOD_image_t image)
Py  : image_hflip(image)
      image_vflip(image)
</pre></p>
<table class="param">
<tr><th>Parameter</th><th>Description</th></tr>
<tr><td>image</td><td>In the C and python version, the image handler, obtained with the <a href="image_load.html">load</a> function.</td></tr>
</table>
Example :<br />
<p class="code"><pre>
C++ : TCODImage *pix = TCODImage("mypix.bmp");
      pix->hflip();
C   : TCOD_image_t pix = TCOD_image_new(80,50);
      TCOD_image_hflip(pix);
Py  : pix = libtcod.image_new(80,50)
      libtcod.image_hflip(pix)
</pre></p>
<br />
You can invert the colors in an image using this function :<br />
<p class="code"><pre>
C++ : void TCODImage::invert()
C   : void TCOD_image_invert(TCOD_image_t image)
Py  : image_invert(image)
</pre></p>
<table class="param">
<tr><th>Parameter</th><th>Description</th></tr>
<tr><td>image</td><td>In the C and python version, the image handler, obtained with the <a href="image_load.html">load</a> function.</td></tr>
</table>
Example :<br />
<p class="code"><pre>
C++ : TCODImage *pix = TCODImage("mypix.bmp");
      pix->invert();
C   : TCOD_image_t pix = TCOD_image_new(80,50);
      TCOD_image_invert(pix);
Py  : pix = libtcod.image_new(80,50)
      libtcod.image_invert(pix)
</pre></p>

